<template>
  <div class="common-layout">
    <!-- 头部标题 -->
    <div class="header-overlay">
      <!-- <div class="header-content" v-if="route.path === '/'"> -->
      <div class="header-content" >
        <h1>欢迎使用供应链管理系统</h1>
        <router-link to="/" v-if="route.path !== '/'">
          <button class="wallet-btn">返回主界面</button>
        </router-link>
        <router-link to="/tx" v-else>
          <button class="wallet-btn">区块链钱包</button>
        </router-link>
      </div>
    </div>
    
    <!-- 根据当前路由决定显示轮播图还是白色背景 -->
    <div v-if="route.path === '/'" class="carousel-container">
      
      <el-carousel height="100vh" trigger="hover" interval="3000">
        <!-- 第一张图片 -->
        <el-carousel-item key="1">
          <div class="carousel-item">
            <img src="http://localhost:8080/img/backend/img1.png" class="carousel-image" alt="轮播图1" />
          </div>
        </el-carousel-item>
        <!-- 第二张图片 -->
        <el-carousel-item key="2">
          <div class="carousel-item">
            <img src="http://localhost:8080/img/backend/img2.png" class="carousel-image" alt="轮播图2" />
          </div>
        </el-carousel-item>
        <!-- 第三张图片 -->
        <el-carousel-item key="3">
          <div class="carousel-item">
            <img src="http://localhost:8080/img/backend/img3.jpg" class="carousel-image" alt="轮播图3" />
          </div>
        </el-carousel-item>
        <!-- 第四张图片 -->
        <el-carousel-item key="4">
          <div class="carousel-item">
            <img src="http://localhost:8080/img/backend/backend2.jpg" class="carousel-image" alt="轮播图4" />
          </div>
        </el-carousel-item>
      </el-carousel>
    </div>
    
    <!-- 非主界面显示白色背景 -->
    <div v-else class="white-background"></div>
    
    <!-- 内容区域 - 登录注册表单 -->
    <div class="content-overlay">
      <RouterView />
    </div>
  </div>
</template>

<script setup>
import { RouterView } from 'vue-router'
import { useRoute } from 'vue-router'

// 获取当前路由信息
const route = useRoute()
</script>

<style scoped>
.common-layout {
  height: 100vh;
  width: 100vw;
  position: relative;
  overflow: hidden;
  background-color: #ffffff;
}

/* 头部标题 - 固定在顶部 */
.header-overlay {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  z-index: 10;
  background: rgba(0, 0, 0, 0.5);
  backdrop-filter: blur(5px);
  box-shadow: var(--shadow-header);
}

.header-content {
  display: flex;
  justify-content: center;
  align-items: center;
  height: 60px;
  width: 100%;
  padding: 0 2rem;
}

.header-content h1 {
  margin: 0;
  font-size: 2rem;
  font-weight: 600;
  color: white;
  text-shadow: 0 2px 4px rgba(0, 0, 0, 0.3);
}

.header-content {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.wallet-btn {
  padding: 8px 16px;
  background-color: #4CAF50;
  color: white;
  border: none;
  border-radius: 4px;
  cursor: pointer;
  font-size: 16px;
  transition: background-color 0.3s ease;
}

.wallet-btn:hover {
  background-color: #45a049;
}

/* 轮播图容器 - 全屏背景 */
.carousel-container {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  z-index: 1;
}

/* 非主界面白色背景 */
.white-background {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  z-index: 1;
  background-color: #ffffff;
}

.el-carousel {
  height: 100vh;
  width: 100vw;
}

.el-carousel__container {
  height: 100%;
}

.carousel-item {
  position: relative;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
}

/* 图片占位样式 */
.image-placeholder {
  font-size: 1.5rem;
  color: #fff;
  text-align: center;
  background: rgba(0, 0, 0, 0.3);
  padding: 2rem;
  border-radius: 8px;
  text-shadow: 0 2px 4px rgba(0, 0, 0, 0.5);
}

/* 建议的图片样式 - 用户添加图片时使用 */
.carousel-image {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

/* 轮播图页面样式 */
.el-carousel__item:nth-child(1) {
  background-color: #99a9bf;
}

.el-carousel__item:nth-child(2) {
  background-color: #d3dce6;
}

.el-carousel__item:nth-child(3) {
  background-color: #e5e9f2;
}

.el-carousel__item:nth-child(4) {
  background-color: #f0f2f5;
}

/* 内容区域 - 登录注册表单覆盖层 */
.content-overlay {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  z-index: 5;
  display: flex;
  padding-top: 60px;
  background-color: transparent;
  overflow-y: auto;
}

/* 响应式设计 */
@media (max-width: 768px) {
  .header-content {
    padding: 1rem;
  }
  
  .header-content h1 {
    font-size: 1.2rem;
  }
  
  .common-layout {
    height: 100vh;
    width: 100vw;
  }
  
  .image-placeholder {
    font-size: 1rem;
    padding: 1rem;
  }
}
</style>